package cn.kgc.service.impl;

import cn.kgc.entities.Goods;
import cn.kgc.mapper.GoodsMapper;
import cn.kgc.service.GoodsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {

    @Resource
    private GoodsMapper goodsMapper;

    @Override
    public List<Goods> getAllGoods() {
        return goodsMapper.selectAll();
    }

    @Override
    public Goods getGoodsById(Integer id) {
        return goodsMapper.selectByPrimaryKey(id);
    }

    @Override
    public void addGoods(Goods goods) {
    goodsMapper.insert(goods);
    }

    @Override
    public void updateGoods(Goods goods) {
    goodsMapper.updateByPrimaryKey(goods);
    }

    @Override
    public void deleteGoodsById(Integer id) {
    goodsMapper.deleteByPrimaryKey(id);
    }
}
